package com.liao.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liao.common.entity.product.SkuAttributeEntity;
import com.liao.common.utils.PageUtils;
import com.liao.common.utils.Query;
import com.liao.product.dao.SkuAttributeDao;
import com.liao.product.service.SkuAttributeService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("skuAttributeService")
public class SkuAttributeServiceImpl extends ServiceImpl<SkuAttributeDao, SkuAttributeEntity> implements SkuAttributeService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SkuAttributeEntity> page = this.page(
                new Query<SkuAttributeEntity>().getPage(params),
                new QueryWrapper<SkuAttributeEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<SkuAttributeEntity> getListByProductId(Integer productId) {
        QueryWrapper<SkuAttributeEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("product_id", productId);
        return this.list(queryWrapper);
    }

}